<?php
namespace app\shop\model;
use app\BaseModel;
use think\facade\Db;



class AdminSellingCash extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_selling_cash_water';

    /**
     * User: chenniang
     * Date: 2019-09-09 15:03
     * @param $value
     * @return false|string
     * descption:转换时间 申请时间
     */
    public function getCreateTimeAttr($value){
        return date('Y-m-d H:i:s',$value);
    }
    /**
     * User: chenniang
     * Date: 2019-09-09 15:04
     * @param $value
     * @return false|string
     * descption:转换时间 到账时间
     */
    public function getUpdateTimeAttr($value){
        return date('Y-m-d H:i:s',$value);
    }
    /**
     * @param $dis
     * @param int $page
     * @return mixed
     * 获取提现列表
     */
    public function cashList($dis,$page = 10) {
        $data = $this
            ->alias('a')
            ->leftJoin('longbing_card_user b' ,'a.user_id = b.id')
            ->leftJoin('longbing_card_user_info c' ,'a.user_id = c.fans_id')
            ->where($dis)
            ->field(['a.*,b.nickName,c.name'])
            ->order('a.status asc')
            ->order('a.id desc')
            ->paginate($page)
            ->toArray();
        return $data;
    }

    /**
     * User: chenniang
     * Date: 2019-09-09 15:16
     * @param $dis
     * @return array|\think\Model|null
     * descption:提现记录详情
     */
    public function cashInfo($dis){
        $data = $this->where($dis)->find();
        return !empty($data)?$data->toArray():$data;

    }

    /**
     * User: chenniang
     * Date: 2019-09-09 15:26
     * @param $dis
     * @param $data
     * @return AdminSellingCash
     * descption:修改提现记录
     */
    public function cashUpdate($dis,$data){
        $data['update_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;
    }



}